package com.neuedu.page_objects;

import com.neuedu.bases.BasePage;
import com.neuedu.bases.InitBrowser;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

public class LoginPage extends BasePage {


    public LoginPage(ChromeDriver driver) {
        super(driver);
    }

    public void login_employee_success()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("123123");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("123123");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public void login_employee_fail()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("123123");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("12312");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }


    public void login_manager_success()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("admin");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("admin");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public void login_manager_fail()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("admin");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("admi");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public void login_maintenance_success()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("112233");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("112233");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public void login_maintenance_fail()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("112233");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("11223");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public String getUserName(){
        return findElement(By.cssSelector("span[class='el-dropdown-link el-dropdown-selfdefine']")).getText();
    }

    public String getLoginFail(){
        return findElement(By.cssSelector("p[class='el-message__content']")).getText();
    }
}
